﻿using D.Medicalcare.ErrorCode;
using D.Medicalcare.Write.API.Application.Commands.MessageCommand;
using D.Medicalcare.Write.API.Helper;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using StackExchange.Redis;

namespace D.Medicalcare.Write.API.Controllers
{
    /// <summary>
    /// 消息公告管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class MessageController : ControllerBase
    {
        private readonly IMediator mediator;
        private readonly IConnectionMultiplexer redis;

        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="mediator">中介者</param>
        public MessageController(IMediator mediator, IConnectionMultiplexer redis)
        {
            this.mediator = mediator;
            this.redis = redis;
        }
        /// <summary>
        /// 添加消息公告
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> CreateMessage(CreateMessageCommand request)
        {
          
            return await mediator.Send(request);
        }
    }
}
